// 生成rsa加密
const { publicKey, privateKey } = require('crypto').generateKeyPairSync('rsa', {
    modulusLength: 4096,
    publicKeyEncoding: {
        type: 'spki',
        format: 'pem'
    },
    privateKeyEncoding: {
        type: 'pkcs8',
        format: 'pem'
    }
});

// 保存密钥到文件
fs.writeFileSync('private.pem', privateKey);
fs.writeFileSync('public.pem', publicKey);